package com.menghao.cloud.service.consumer;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * <p>Todo.<br>
 *
 * @author MarvelCode.
 */
@Service
public class HelloServiceImpl {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "helloHystrix")
    public String hello() {
        return restTemplate.getForEntity("http://service-provider/hello", String.class).getBody();
    }

    public String helloHystrix() {
        return "sorry,service lost";
    }
}
